import java.util.ArrayDeque;

public class MyQueueUsStack {
    public ArrayDeque<Integer> s1;
    public ArrayDeque<Integer> s2;

    public MyQueueUsStack(){
        s1 = new ArrayDeque<>();
        s2 = new ArrayDeque<>();
    }

    // 入队操作，直接将元素压入第一个栈
    public void push(int x){
        s1.push(x);
    }

    public int pop(){
        if(empty()){
            return -1;
        }
        if(s2.isEmpty()){
            // 如果第二个栈为空，则将第一个栈中的元素全部转移到第二个栈
            while (!s1.isEmpty()){
                s2.push(s1.pop());
            }
        }
        return s2.pop();
    }

    public int peek(){
        if(empty()){
            return -1;
        }
        if(s2.isEmpty()){
            while (!s1.isEmpty()){
                s2.push(s1.pop());
            }
        }
        return s2.peek();
    }

    public boolean empty(){
        return s1.isEmpty() && s2.isEmpty();
    }
}
